<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>My Engine: my::TriggeringTimer Class Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">My Engine
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><b>my</b>      </li>
      <li class="navelem"><a class="el" href="classmy_1_1_triggering_timer.html">TriggeringTimer</a>      </li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a>  </div>
  <div class="headertitle">
<div class="title">my::TriggeringTimer Class Reference</div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="my::TriggeringTimer" --><!-- doxytag: inherits="my::Timer,my::EventHandling" -->
<p>Create a <a class="el" href="classmy_1_1_triggering_timer.html" title="Create a TriggeringTimer. A TriggeringTimer is a Timer that call a binded slot (function or class mem...">TriggeringTimer</a>. A <a class="el" href="classmy_1_1_triggering_timer.html" title="Create a TriggeringTimer. A TriggeringTimer is a Timer that call a binded slot (function or class mem...">TriggeringTimer</a> is a <a class="el" href="classmy_1_1_timer.html" title="Create a Timer. A Timer is a watch that starts at a given time and that decrease to reach zero...">Timer</a> that call a binded slot (function or class member) when it reaches zero.<br/>
 Lets see how we can use it with a simple function :<br/>
.  
 <a href="classmy_1_1_triggering_timer.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="_triggering_timer_8h_source.html">TriggeringTimer.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for my::TriggeringTimer:</div>
<div class="dyncontent">
 <div class="center">
  <img src="classmy_1_1_triggering_timer.png" usemap="#my::TriggeringTimer_map" alt=""/>
  <map id="my::TriggeringTimer_map" name="my::TriggeringTimer_map">
<area href="classmy_1_1_timer.html" title="Create a Timer. A Timer is a watch that starts at a given time and that decrease to reach zero..." alt="my::Timer" shape="rect" coords="0,0,123,24"/>
<area href="classmy_1_1_event_handling.html" title="Pure Virtual class that provide a simple Signal/Slot system.  A Signal is a string and a Slot is a fu..." alt="my::EventHandling" shape="rect" coords="133,0,256,24"/>
</map>
 </div></div>

<p><a href="classmy_1_1_triggering_timer-members.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a7d8c19d87a13a04053443f065a627048"></a><!-- doxytag: member="my::TriggeringTimer::TriggeringTimer" ref="a7d8c19d87a13a04053443f065a627048" args="()" -->
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmy_1_1_triggering_timer.html#a7d8c19d87a13a04053443f065a627048">TriggeringTimer</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Default Constructor. To use the <a class="el" href="classmy_1_1_timer.html" title="Create a Timer. A Timer is a watch that starts at a given time and that decrease to reach zero...">Timer</a> you will need to use <a class="el" href="classmy_1_1_triggering_timer.html#aa3d081edf90ddb62d3af0c41fea39ed1" title="To reset the Timer.">reset(float timeLimit, bool continueRunning)</a>. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmy_1_1_triggering_timer.html#ab0e2ba79d9cbfd9844de3646306cf839">TriggeringTimer</a> (float timeLimit, bool initRunning=false, bool loopRunning=false)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Recommended constructor.  <a href="#ab0e2ba79d9cbfd9844de3646306cf839"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ab2a1fa34f5de89d458878c1bdf6690be"></a><!-- doxytag: member="my::TriggeringTimer::~TriggeringTimer" ref="ab2a1fa34f5de89d458878c1bdf6690be" args="()" -->
virtual&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmy_1_1_triggering_timer.html#ab2a1fa34f5de89d458878c1bdf6690be">~TriggeringTimer</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Default destructor. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmy_1_1_triggering_timer.html#a39a7de0bbdbbbe7c52636133068869fd">setLoopRunning</a> (bool active=true)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">To set or unset the auto restarting.  <a href="#a39a7de0bbdbbbe7c52636133068869fd"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmy_1_1_triggering_timer.html#a04333fbd92d06473372c965c6868ddeb">loopRunning</a> () const </td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Is the loop running activated ?  <a href="#a04333fbd92d06473372c965c6868ddeb"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmy_1_1_triggering_timer.html#aa3d081edf90ddb62d3af0c41fea39ed1">reset</a> (float timeLimit, bool keepRunning=false)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">To reset the <a class="el" href="classmy_1_1_timer.html" title="Create a Timer. A Timer is a watch that starts at a given time and that decrease to reach zero...">Timer</a>.  <a href="#aa3d081edf90ddb62d3af0c41fea39ed1"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmy_1_1_triggering_timer.html#a6ec4744e75c4b1550e9a7e4500aaa941">reset</a> (bool keepRunning=false)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">To reset the <a class="el" href="classmy_1_1_timer.html" title="Create a Timer. A Timer is a watch that starts at a given time and that decrease to reach zero...">Timer</a>, the old time limit will be kept.  <a href="#a6ec4744e75c4b1550e9a7e4500aaa941"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmy_1_1_triggering_timer.html#ae340972bdb663d22f2da709a3a692352">bind</a> (my::slot function)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Bind the expiration of the time with a slot.  <a href="#ae340972bdb663d22f2da709a3a692352"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a83c5cfadc46da3de5114cc077d468030"></a><!-- doxytag: member="my::TriggeringTimer::update" ref="a83c5cfadc46da3de5114cc077d468030" args="()" -->
void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmy_1_1_triggering_timer.html#a83c5cfadc46da3de5114cc077d468030">update</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Update the timer and call the slot binded at expiration. Should be called once a main loop. <br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>Create a <a class="el" href="classmy_1_1_triggering_timer.html" title="Create a TriggeringTimer. A TriggeringTimer is a Timer that call a binded slot (function or class mem...">TriggeringTimer</a>. A <a class="el" href="classmy_1_1_triggering_timer.html" title="Create a TriggeringTimer. A TriggeringTimer is a Timer that call a binded slot (function or class mem...">TriggeringTimer</a> is a <a class="el" href="classmy_1_1_timer.html" title="Create a Timer. A Timer is a watch that starts at a given time and that decrease to reach zero...">Timer</a> that call a binded slot (function or class member) when it reaches zero.<br/>
 Lets see how we can use it with a simple function :<br/>
. </p>
<div class="fragment"><pre class="fragment"><span class="comment">// The function needs to take no arguments and to return nothing</span>
<span class="keywordtype">void</span> foo(<span class="keywordtype">void</span>)
{
    <span class="comment">// Do something...</span>
}

<span class="keywordtype">int</span> main(<span class="keywordtype">void</span>)
{
    <a class="code" href="classmy_1_1_triggering_timer.html" title="Create a TriggeringTimer. A TriggeringTimer is a Timer that call a binded slot (function or class mem...">my::TriggeringTimer</a> timer(5.f, <span class="keyword">false</span>, <span class="keyword">true</span>); <span class="comment">// Create a timer of 5.0 seconds, don&#39;t start it immediatly, set auto restarting</span>
    timer.bind(foo); <span class="comment">// Bind a function to call every 5.0 seconds</span>

    timer.start(); <span class="comment">// Start the timer</span>
    <span class="keywordflow">while</span>(<span class="keyword">true</span>)
    {
        timer.update(); <span class="comment">// Updating the timer so when it will be expired, the binded function will be called</span>
        <span class="comment">// foo() is automatically called after 5 seconds, and because of the auto-restarting, it will be</span>
        <span class="comment">// called every 5 seconds ! No need to check ourselves if the timer has expired !</span>
    }

}
</pre></div><p> The code above automatically call a function after a given time. <br/>
 <br/>
 This code do the same but with an object method (using boost::bind, already included) : </p>
<div class="fragment"><pre class="fragment"><span class="keyword">struct </span>Foo
{
    <span class="keywordtype">void</span> bar(<span class="keywordtype">void</span>)
    {
        <span class="comment">// Do something...</span>
    }
};

<span class="keywordtype">int</span> main(<span class="keywordtype">void</span>)
{
    Foo my_foo; <span class="comment">// Creating some foo stuff</span>
    <a class="code" href="classmy_1_1_triggering_timer.html" title="Create a TriggeringTimer. A TriggeringTimer is a Timer that call a binded slot (function or class mem...">my::TriggeringTimer</a> timer(5.f, <span class="keyword">false</span>, <span class="keyword">true</span>); <span class="comment">// Create a timer of 5.0 seconds, don&#39;t start it immediatly, set auto restarting</span>
    timer.bind(boost::bind(&amp;Foo::bar, &amp;my_foo)); <span class="comment">// Bind a class method to call every 5.0 seconds</span>

    timer.start(); <span class="comment">// Start the timer</span>
    <span class="keywordflow">while</span>(<span class="keyword">true</span>)
    {
        timer.update(); <span class="comment">// Updating the timer so when it will be expired, the binded method will be called</span>
        <span class="comment">// my_foo.bar() is automatically called after 5 seconds, and because of the auto-restarting, it will be</span>
        <span class="comment">// called every 5 seconds ! No need to check ourselves if the timer has expired !</span>
    }

}
</pre></div> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="classmy_1_1_timer.html" title="Create a Timer. A Timer is a watch that starts at a given time and that decrease to reach zero...">Timer</a> </dd></dl>
</div><hr/><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="ab0e2ba79d9cbfd9844de3646306cf839"></a><!-- doxytag: member="my::TriggeringTimer::TriggeringTimer" ref="ab0e2ba79d9cbfd9844de3646306cf839" args="(float timeLimit, bool initRunning=false, bool loopRunning=false)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">my::TriggeringTimer::TriggeringTimer </td>
          <td>(</td>
          <td class="paramtype">float&#160;</td>
          <td class="paramname"><em>timeLimit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>initRunning</em> = <code>false</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>loopRunning</em> = <code>false</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Recommended constructor. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">timeLimit</td><td>The starting time of the <a class="el" href="classmy_1_1_timer.html" title="Create a Timer. A Timer is a watch that starts at a given time and that decrease to reach zero...">Timer</a>. It will decrease to zero. </td></tr>
    <tr><td class="paramname">initRunning</td><td>Set it true if you want to start the timer at construction </td></tr>
    <tr><td class="paramname">loopRunning</td><td>Set it true if you want to restart the time when expired </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="ae340972bdb663d22f2da709a3a692352"></a><!-- doxytag: member="my::TriggeringTimer::bind" ref="ae340972bdb663d22f2da709a3a692352" args="(my::slot function)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void my::TriggeringTimer::bind </td>
          <td>(</td>
          <td class="paramtype">my::slot&#160;</td>
          <td class="paramname"><em>function</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Bind the expiration of the time with a slot. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">function</td><td>A my::slot to call at timer expiration. You can use boost::bind to bind a object member, else use a function. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a04333fbd92d06473372c965c6868ddeb"></a><!-- doxytag: member="my::TriggeringTimer::loopRunning" ref="a04333fbd92d06473372c965c6868ddeb" args="() const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool my::TriggeringTimer::loopRunning </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Is the loop running activated ? </p>
<dl class="return"><dt><b>Returns:</b></dt><dd>true if the loop running is activated, else return false </dd></dl>

</div>
</div>
<a class="anchor" id="aa3d081edf90ddb62d3af0c41fea39ed1"></a><!-- doxytag: member="my::TriggeringTimer::reset" ref="aa3d081edf90ddb62d3af0c41fea39ed1" args="(float timeLimit, bool keepRunning=false)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void my::TriggeringTimer::reset </td>
          <td>(</td>
          <td class="paramtype">float&#160;</td>
          <td class="paramname"><em>timeLimit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>keepRunning</em> = <code>false</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>To reset the <a class="el" href="classmy_1_1_timer.html" title="Create a Timer. A Timer is a watch that starts at a given time and that decrease to reach zero...">Timer</a>. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">timeLimit</td><td>The starting time of the <a class="el" href="classmy_1_1_timer.html" title="Create a Timer. A Timer is a watch that starts at a given time and that decrease to reach zero...">Timer</a>. It will decrease to zero. </td></tr>
    <tr><td class="paramname">keepRunning</td><td>Set it true if you want to restart the timer </td></tr>
  </table>
  </dd>
</dl>

<p>Reimplemented from <a class="el" href="classmy_1_1_timer.html#a89251f4fb94c50022d9ef0ce103716ff">my::Timer</a>.</p>

</div>
</div>
<a class="anchor" id="a6ec4744e75c4b1550e9a7e4500aaa941"></a><!-- doxytag: member="my::TriggeringTimer::reset" ref="a6ec4744e75c4b1550e9a7e4500aaa941" args="(bool keepRunning=false)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void my::TriggeringTimer::reset </td>
          <td>(</td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>keepRunning</em> = <code>false</code></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>To reset the <a class="el" href="classmy_1_1_timer.html" title="Create a Timer. A Timer is a watch that starts at a given time and that decrease to reach zero...">Timer</a>, the old time limit will be kept. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">keepRunning</td><td>Set it true if you want to restart the timer </td></tr>
  </table>
  </dd>
</dl>

<p>Reimplemented from <a class="el" href="classmy_1_1_timer.html#accc5932c402ba5fd4ab65460d9d44f2a">my::Timer</a>.</p>

</div>
</div>
<a class="anchor" id="a39a7de0bbdbbbe7c52636133068869fd"></a><!-- doxytag: member="my::TriggeringTimer::setLoopRunning" ref="a39a7de0bbdbbbe7c52636133068869fd" args="(bool active=true)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void my::TriggeringTimer::setLoopRunning </td>
          <td>(</td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>active</em> = <code>true</code></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>To set or unset the auto restarting. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">active</td><td>Set ir true if you want to restart the timer when expired, else set it false </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>Time/<a class="el" href="_triggering_timer_8h_source.html">TriggeringTimer.h</a></li>
<li>TriggeringTimer.cpp</li>
</ul>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr class="footer"/><address class="footer"><small>
Generated on Fri Nov 18 2011 22:34:34 for My Engine by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.5.1
</small></address>

</body>
</html>
